/**
 * version: 1.0.0
 * author : wskeee
 * update : "2013-4-9 16:42:30"
 * des	  : as3 组件
 **/
package com.wskeee.ec.core
{
	import com.wskeee.ec.components.Alert;
	import com.wskeee.ec.managers.ComponentManager;
	import com.wskeee.ec.managers.IComponentManager;
	import com.wskeee.ec.managers.IFocusManager;
	import com.wskeee.ec.managers.IRenderManager;
	import com.wskeee.ec.managers.IToolTipManager;
	import com.wskeee.ec.managers.KeyboardManager;
	import com.wskeee.ec.managers.RenderManager;
	import com.wskeee.ec.managers.ResourceManager;
	import com.wskeee.ec.managers.StyleManager;
	import com.wskeee.ec.managers.ToolTipManager;
	import com.wskeee.ec.styles.DefaultStyle;
	import com.wskeee.ec.styles.Icons;
	
	import flash.display.Stage;
	
	public class EGlobal
	{
		public static var isUseIDESkin:Boolean = false;
		public static var stage:Stage;
		public static var ideSkinName:String = "ecskin";
		
		public static var componentManager:IComponentManager;
		public static var renderManager:IRenderManager;
		public static var toolTipManager:IToolTipManager;
		public static var focusManager:IFocusManager;
		public static var keyboardManager:KeyboardManager;
		public static var resourceManager:ResourceManager;
		public static var styleManager:StyleManager;
		
		public static function initialize(_stage:Stage):void
		{
			stage = _stage;
			Alert.stage = stage;
			
			renderManager = new RenderManager(stage);
			componentManager = new ComponentManager();
			keyboardManager = new KeyboardManager(stage);
			toolTipManager = new ToolTipManager(stage);
			resourceManager = new ResourceManager();
			styleManager = new StyleManager();
			
			setComponentDefalutStyle();
			useIDESkin = false;
		}
		
		/**
		 * 设置组件默认样式 
		 * 
		 */
		private static function setComponentDefalutStyle():void
		{
			for(var i:String in DefaultStyle.componentsDefautStyle)
				styleManager.setStyle(i,DefaultStyle.componentsDefautStyle[i]);
		}
		
		/**
		 * 设置组件使用 ide 样式 
		 * @param bo
		 * 
		 */
		public static function set useIDESkin(bo:Boolean):void
		{
			isUseIDESkin = bo;
			reflashStyle();
		}
		
		/**
		 * 刷新所有组件样式 
		 * 
		 */
		public static function reflashStyle():void
		{ 
			isUseIDESkin ? Icons.createIconByIDE() : Icons.createDefaultIcon(true);
			componentManager.callComponentsFun("reflashStyle");
		}
		
		/**
		 * 设置 ide style，使用默认样式，content null 
		 * @param content
		 * 
		 */
		public static function set ideSkin(content:Object):void
		{
			useIDESkin = content ? true : false;
			resourceManager.addResource(content);
			useIDESkin = isUseIDESkin
		}
	}
}